<template>
	<div class="icons">
		<swiper :options="swiperOption">
			<swiper-slide v-for="(page, index) of pages" :key="index">
				<div class="icon" v-for="item of page" :key="item.id">
					<div class="icon-img">
						<img class="icon-img-info" :src="item.imgUrl" />
					</div>
					<p class="icon-img-desc">{{item.imgDesc}}</p>
				</div>
			</swiper-slide>
			<div class="swiper-pagination"  slot="pagination"></div>
		</swiper>
	</div>
</template>

<script>
export default {
  name: 'HomeIcons',
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination'
      }
    }
  },
  props: {
    iconList: Array
  },
  computed: {
    pages () {
      const pages = []
      this.iconList.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '~styles/variable.styl'
	.icons >>> .swiper-container
		height: 100%
	.icons >>> .swiper-pagination-bullet-active
		background: #33bfcb
	.icons >>> .swiper-pagination-bullet
		width: 6px
		height: 6px
	.icons >>> .swiper-container-horizontal > .swiper-pagination-bullets
		bottom: 5px
	.icons
		overflow: hidden
		height: 3.7rem
		color: $iconColor
		.icon
			width: 25%
			/*height: 1.6rem*/
			float: left
			overflow: hidden
			text-align: center
			.icon-img
				width: 1.1rem
				height: 1.1rem
				display: inline-block
				padding: .1rem 0
				.icon-img-info
					width: 100%
			.icon-img-desc
				font-size: .28rem
</style>
